#include "myprocessplayer.h"
#include "ui_myprocessplayer.h"

MyProcessPlayer::MyProcessPlayer(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MyProcessPlayer)
{
    ui->setupUi(this);
    connect(&mprocess, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(start_process(int,QProcess::ExitStatus)));
}

MyProcessPlayer::~MyProcessPlayer()
{
    delete ui;
}

void MyProcessPlayer::on_palyerBt_clicked()
{
    //mplayer.exe -slave -wid id号 1.mp4 //把mplayer嵌入到qt界面中
    QStringList arglist;
    arglist<<"-slave";  //mplayer从模式可以接终端写入的数据（管道通信）
    arglist<<"-wid";
    arglist<<QString::number(ui->widget->winId());
    arglist<<"C:/Users/asus/Music/MV/1.mp4";
    mprocess.start("C:/Users/asus/Desktop/qt/MPlayer for Windows/mplayer.exe",arglist);
}

void MyProcessPlayer::on_pauseBt_clicked()
{
    mprocess.write("pause\n");   //暂停或播放
}
void  MyProcessPlayer::start_process(int,QProcess::ExitStatus)
{
    //mplayer.exe -slave -wid id号 1.mp4 //把mplayer嵌入到qt界面中
    QStringList arglist;
    arglist<<"-slave";  //mplayer从模式可以接终端写入的数据（管道通信）
    arglist<<"-wid";
    arglist<<QString::number(ui->widget->winId());
    arglist<<"C:/Users/asus/Music/MV/1.mp4";
    mprocess.start("C:/Users/asus/Desktop/QQLive/QQLive.exe",arglist);

}
